<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取贷款申请信息</title>
  <script language="javascript" type="text/javascript" src="../vue/vue2.x.js"></script>
  <script language="javascript" type="text/javascript" src="../elementUI/elementUI2.x.js"></script>
  <!--        <link rel="stylesheet" href="elementUI/elementUI2.x.css" type="text/css">-->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <style type="text/css">
    *{
      margin: 0;
      padding: 0;
    }
    .el-collapse-item__header>span{
      margin-left: 60px;
    }
    .el-collapse-item__header>span:first-child{
      margin:0;
    }
    .el-collapse-item__header.is-active{
      background-color: #b8e0ab;
    }
    .files-div{
      display: inline-block;
      width: 33.33%;
      vertical-align: top;
    }
    h3,h4,p{
      display: inline-block;
    }
    #content{
      font-size: 16px;
      padding-top: 20px;
    }
   .el-rate{
      display: inline-block;
   }
  </style>
</head>
<body>
  <div id="app">
    <el-collapse accordion>
      <el-collapse-item v-for="item in loansData">
        <template slot="title">
          <span id="user_mail">账户：{{ item.user_mail }}</span>
          <span id="user_name">用户昵称：{{ item.user_name }}</span>
          <span id="loans_date">提交时间：{{ item.Loans_date }}</span>
          <span id="due_date">预计还款时间：{{ item.Due_date }}</span>
          <span id="stateType">状态：<el-tag :type="item.stateType">{{ item.Loans_state }}</el-tag></span>
          <el-select style="margin-left: 80px;width:120px" v-model="item.loansState" @change="optionChange(item.Loans_id,item.loansState)">
            <el-option
                    v-for="i in options"
                    :key="i.value"
                    :label="i.label"
                    :value="i.value">
            </el-option>
          </el-select>
        </template>
        <div id="content">
          <div><h4>性别：</h4><span>{{ item.user_sex }}</span></div>
          <div><h4>生日：</h4><span>{{ item.user_birthday }}</span></div>
          <div><h4>身份证号：</h4><span>{{ item.id_card }}</span></div>
          <div><h4>银行卡号：</h4><span>{{ item.rand_card }}</span></div>
          <div><h4>用户信誉度：</h4>
            <el-rate
                  disabled
                  :value="item.user_reputation"
                  :colors="colors">
            </el-rate>
          </div>
          <div><h3>详细描述：</h3><p>{{ item.Loans_purpose }}</p></div>
          <div class="files-div" v-for="subItem,subKey in item.fileImg">
            <div>{{ subKey }}: </div><img style="width:200px;height: 150px;border-radius: 20px" :src="'../'+subItem">
          </div>
        </div>
      </el-collapse-item>
    </el-collapse>
  </div>
  <script type="text/javascript">
    var vm = new Vue({
      el:'#app',
      data: {
        loansData:[],
        colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
        options: [{
          value: 1,
          label: '请操作'
        }, {
          value: 2,
          label: '正在处理'
        }, {
          value: 3,
          label: '处理完成'
        }, {
          value: 4,
          label: '驳回'
        }]
      },
      mounted: function () {
        //加载信息
        axios.get('/admin/getLoansInfo').then((resp) => {
          console.log(resp.data);
          this.loansData = resp.data;

        }).catch((err) => {
          console.log(err)
        });
      },
      methods:{
        optionChange: function(id,value){
          console.log(id);
          console.log(value);
          var formDate = new FormData();
          formDate.append("loans_id",id);
          formDate.append("loans_state",value);
          //修改业务状态
          axios.post('/admin/updateLoansState',formDate).then((resp) => {
            if(resp.data===true){
              vm.$message({
                type:'success',
                message: "操作成功"
              })
              setTimeout(function(){
                window.location.reload();
              },1000)
            }else {
              vm.$message({
                type:'error',
                message: "操作失败"
              })
            }
          }).catch((err) => {
            console.log(err)
          });
        }
      }
    })
  </script>
</body>
</html>
